package com.dxysun.design.factory.factormethod;

import java.util.HashMap;
import java.util.Map;

public class RuleConfigParserFactoryMethod
{
	private static final Map<String, IRuleConfigParserFactory> cachedFactories = new HashMap<>();

	static
	{
		cachedFactories.put("json", new JsonRuleConfigParserFactory());
		cachedFactories.put("xml", new XmlRuleConfigParserFactory());
	}

	public static IRuleConfigParserFactory getParserFactory(String type)
	{
		if (type == null || type.isEmpty())
		{
			return null;
		}
		return cachedFactories.get(type.toLowerCase());
	}
}
